package com.test.cloud.consumer.controller;

import com.test.cloud.consumer.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

/**
 * @author 徒有琴
 */
@Controller
public class ConsumerController {

    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("test.html")
    public String test(Integer id, Model model) {
        User user = restTemplate.getForObject("http://SERVICE-PROVIDER/simple/" + id, User.class);
        model.addAttribute("user", user);
        return "index";
    }
}
